var Mock = require('mockjs');
var Random = Mock.Random;

// 获取轮播图图片
Mock.mock('/home/api/getLunbotu', 'get', [{
    hrefUrl: Random.url('https'),
    imgUrl: '/src/source/image/lunbotu001.webp'
}, {
    hrefUrl: Random.url('https'),
    imgUrl: '/src/source/image/lunbotu002.webp'
}, {
    hrefUrl: Random.url('https'),
    imgUrl: '/src/source/image/lunbotu003.webp'
}, {
    hrefUrl: Random.url('https'),
    imgUrl: '/src/source/image/lunbotu004.webp'
}, {
    hrefUrl: Random.url('https'),
    imgUrl: '/src/source/image/lunbotu005.webp'
}]);


// 登录
Mock.mock('/login', 'post', function (data) {
    var data2 = data.body;
    var userid = data.body.userid;
    var password = data.body.password;
    if (typeof (data.body) === 'string') {
        var strList = data.body.split(':');
        userid = strList[1].split('"')[1];
        password = strList[2].split('"')[1];
    }
    if (userid === 'Hsc' && password === 'hsc') {
        return {
            status: 0,
            message: '登录成功',
            data: {
                token: 'hkjashdjkasdkjahoahdasiudahdkjah',
                username: 'Hsc',
                userImgUrl: '/src/source/image/user.png'
            }
        }
    } else {
        return {
            status: 1,
            message: '账号或密码错误'
        }
    }
});

// token登录
Mock.mock('/getUserInfoByToken', 'post', function (data) {
    return {
        status: 0,
        message: '登录成功',
        data: {
            token: 'hkjashdjkasdkjahoahdasiudahdkjah',
            username: 'Hsc',
            userImgUrl: '/src/source/image/user.png'
        }
    }
});



// 分类的接口
Mock.mock('/sort/getSorts', 'get', [{ title: '推荐分类', id: 1 },
{ title: '京东超市', id: 2 }, { title: '国际名牌', id: 3 }, { title: '奢侈品', id: 4 },
{ title: '唯品会', id: 5 }, { title: '男装', id: 6 }, { title: '女装', id: 7 },
{ title: '男鞋', id: 8 }, { title: '女鞋', id: 9 }, { title: '内衣配饰', id: 10 },
{ title: '箱包手袋', id: 11 }, { title: '美妆护肤', id: 12 }, { title: '个护清洁', id: 13 },
{ title: '钟表珠宝', id: 14 }, { title: '手机数码', id: 15 }, { title: '电脑办公', id: 16 }]);

// 详细分类接口
Mock.mock('/sort/getSorts/1', 'get', [{
    title: '推荐分类',
    sortList: [{ id: 1001, title: '手机', imgUrl: '/src/source/image/goods/cpu/cpu001.jpg' }, { id: 1002, title: '耳机', imgUrl: '/src/source/image/goods/cpu/cpu002.jpg' }, { id: 1001, title: '华为', imgUrl: '/src/source/image/goods/cpu/cpu003.jpg' }
        , { id: 1001, title: '电饭煲', imgUrl: '/src/source/image/goods/cpu/cpu010.jpg' }, { id: 1001, title: '电磁炉', imgUrl: '/src/source/image/goods/cpu/cpu007.jpg' }, { id: 1001, title: '路由器', imgUrl: '/src/source/image/goods/cpu/cpu004.jpg' }
        , { id: 1001, title: '口红', imgUrl: '/src/source/image/goods/cpu/cpu001.jpg' }, { id: 1001, title: '吹风机', imgUrl: '/src/source/image/goods/cpu/cpu008.jpg' }, { id: 1001, title: '三只松鼠', imgUrl: '/src/source/image/goods/cpu/cpu005.jpg' }
        , { id: 1001, title: '洗衣液', imgUrl: '/src/source/image/goods/cpu/cpu002.jpg' }, { id: 1001, title: '保温杯', imgUrl: '/src/source/image/goods/cpu/cpu009.jpg' }, { id: 1001, title: '耳机', imgUrl: '/src/source/image/goods/cpu/cpu006.jpg' }]
},
{
    title: '家电热搜',
    sortList: [{ id: 1001, title: '手机', imgUrl: '/src/source/image/goods/cpu/cpu001.jpg' }, { id: 1002, title: '耳机', imgUrl: '/src/source/image/goods/cpu/cpu002.jpg' }, { id: 1001, title: '华为', imgUrl: '/src/source/image/goods/cpu/cpu003.jpg' }
        , { id: 1001, title: '电饭煲', imgUrl: '/src/source/image/goods/cpu/cpu010.jpg' }, { id: 1001, title: '电磁炉', imgUrl: '/src/source/image/goods/cpu/cpu007.jpg' }, { id: 1001, title: '路由器', imgUrl: '/src/source/image/goods/cpu/cpu004.jpg' }
        , { id: 1001, title: '口红', imgUrl: '/src/source/image/goods/cpu/cpu001.jpg' }, { id: 1001, title: '吹风机', imgUrl: '/src/source/image/goods/cpu/cpu008.jpg' }, { id: 1001, title: '三只松鼠', imgUrl: '/src/source/image/goods/cpu/cpu005.jpg' }]
}]);

Mock.mock('/sort/getSorts/2', 'get', [{
    title: '其它分类',
    sortList: [{ id: 1001, title: '手机', imgUrl: '/src/source/image/goods/phone/phone001.jpg' }, { id: 1002, title: '耳机', imgUrl: '/src/source/image/goods/phone/phone002.jpg' }, { id: 1001, title: '华为', imgUrl: '/src/source/image/goods/phone/phone003.jpg' }
        , { id: 1001, title: '电饭煲', imgUrl: '/src/source/image/goods/phone/phone010.jpg' }, { id: 1001, title: '电磁炉', imgUrl: '/src/source/image/goods/phone/phone007.jpg' }, { id: 1001, title: '路由器', imgUrl: '/src/source/image/goods/phone/phone004.jpg' }
        , { id: 1001, title: '口红', imgUrl: '/src/source/image/goods/phone/phone001.jpg' }, { id: 1001, title: '吹风机', imgUrl: '/src/source/image/goods/phone/phone008.jpg' }, { id: 1001, title: '三只松鼠', imgUrl: '/src/source/image/goods/phone/phone005.jpg' }
        , { id: 1001, title: '洗衣液', imgUrl: '/src/source/image/goods/phone/phone002.jpg' }, { id: 1001, title: '保温杯', imgUrl: '/src/source/image/goods/phone/phone009.jpg' }, { id: 1001, title: '耳机', imgUrl: '/src/source/image/goods/phone/phone006.jpg' }]
},
{
    title: '手机热搜',
    sortList: [{ id: 1001, title: '手机', imgUrl: '/src/source/image/goods/cpu/cpu001.jpg' }, { id: 1002, title: '耳机', imgUrl: '/src/source/image/goods/cpu/cpu002.jpg' }, { id: 1001, title: '华为', imgUrl: '/src/source/image/goods/cpu/cpu003.jpg' }
        , { id: 1001, title: '电饭煲', imgUrl: '/src/source/image/goods/cpu/cpu010.jpg' }, { id: 1001, title: '电磁炉', imgUrl: '/src/source/image/goods/cpu/cpu007.jpg' }, { id: 1001, title: '路由器', imgUrl: '/src/source/image/goods/cpu/cpu004.jpg' }
        , { id: 1001, title: '口红', imgUrl: '/src/source/image/goods/cpu/cpu001.jpg' }, { id: 1001, title: '吹风机', imgUrl: '/src/source/image/goods/cpu/cpu008.jpg' }, { id: 1001, title: '三只松鼠', imgUrl: '/src/source/image/goods/cpu/cpu005.jpg' }]
}]);


// 商品的接口
Mock.mock('/sort/goodsList/phone', 'get', [{
    imgUrl: '/src/source/image/goods/phone/phone001.jpg',
    name: '小米 MX8 至尊版',
    oldCost: 4999,
    cost: 3999,
    remainder: 60,
    id: 1
}, {
    imgUrl: '/src/source/image/goods/phone/phone002.jpg',
    name: '小米 MX8 至尊版aaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    oldCost: 4999,
    cost: 3999,
    remainder: 60,
    id: 2
}, {
    imgUrl: '/src/source/image/goods/phone/phone003.jpg',
    name: '小米 MX8 至尊版',
    oldCost: 4999,
    cost: 3999,
    remainder: 60,
    id: 3
}, {
    imgUrl: '/src/source/image/goods/phone/phone001.jpg',
    name: '小米 MX8 至尊版',
    oldCost: 4999,
    cost: 3999,
    remainder: 60,
    id: 4
}, {
    imgUrl: '/src/source/image/goods/phone/phone002.jpg',
    name: '小米 MX8 至尊版',
    oldCost: 4999,
    cost: 3999,
    remainder: 60,
    id: 5
}, {
    imgUrl: '/src/source/image/goods/phone/phone003.jpg',
    name: '小米 MX8 至尊版',
    oldCost: 4999,
    cost: 3999,
    remainder: 60,
    id: 6
}]);


// 获取商品详细信息
Mock.mock('/goodsinfo/10001', 'get', {
    name: '小米 MX8 至尊版aaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    imgUrls: [{ hrefUrl: Random.url('https'), imgUrl: '/src/source/image/goods/phone/phone003.jpg' },
    { hrefUrl: Random.url('https'), imgUrl: '/src/source/image/goods/phone/phone008.jpg' },
    { hrefUrl: Random.url('https'), imgUrl: '/src/source/image/goods/phone/phone005.jpg' }],
    oldCost: 4999,
    cost: 3999,
    remainder: 60,
    id: 10001,
    described: '本产品全国联保，享受三包服务，质保期为：一年质保如因质量问题或故障，凭厂商维修中心或特约维修点的质量检测证明，享受7日内退货，15日内换货，15日以上在质保期内享受免费保修等三包服务！(注:如厂家在商品介绍中有售后保障的说明,则此商品按照厂家说明执行售后保障服务。) 您可以查询本品牌在各地售后服务中心的联系方式，请点击这儿查询......'
});

// 获取用户购物车信息
Mock.mock('/getcarinfo/1111', 'get', {
    status: 0,
    data: [{
        id: 10001,
        name: '小米 MX8 至尊版aaaaaaaaaaaaaaaaaaaaaaaaaaaa',
        count: 1,
        singleCost: 3999,
        selected: true,
        imgUrl: '/src/source/image/goods/phone/phone008.jpg'
    }, {
        id: 10002,
        name: '苹果 ms8 土豪金版',
        count: 8,
        singleCost: 5999,
        selected: true,
        imgUrl: '/src/source/image/goods/phone/phone009.jpg'
    }, {
        id: 10003,
        name: '小米 MX8 至尊版',
        count: 5,
        singleCost: 8999,
        selected: true,
        imgUrl: '/src/source/image/goods/phone/phone010.jpg'
    }]
});

Mock.setup({
    timeout: '400'
});